<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="tra" value="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHppRtQ75DyRCRE0EBWFKG8TDLLjrzDj5Uejy2
kbAhLJI8CB9HjnSe0gNjSjMsRuYHv2ai8bf+1B3N1LoKAA7nRi8vlYZUu04wCkD3n5bsrGCSjkI+
Hobbkw9cuDWdn/INFguLpx4MT1s4PfIlRT/QDzCMHH9zbtu04SjY/HeHFQIDAQAB">
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

<script src="jsencrypt.min.js"></script>
<script>
    /* 加密 */
    var encrypt = new JSEncrypt();
    encrypt.setPublicKey('公钥');
    var data = encrypt.encrypt(JSON.stringify({ddd:"ccc"}));
    //data=encodeURI(data).replace(/\+/g, '%2B')//+号的处理：因为数据在网络上传输时，非字母数字字符都将被替换成百分号（%）后跟两位十六进制数，而base64编码在传输到后端的时候，+会变成空格，因此先替换掉。后端再替换回来
    console.log(data);
    /*解密*/
    //data=encodeURIComponent(data.replace(/[%2B]+/g,'+'));
    encrypt.setPrivateKey('私钥')
    data=encrypt.decrypt(data)
    console.log(JSON.parse(data));
</script>
</body>
</html>